package com.sali.rbac.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sali.rbac.convert.SysUserConvertDO2Model;
import com.sali.rbac.mapper.SysUserMapper;
import com.sali.rbac.model.SysUserModel;
import com.sali.rbac.orm.SysUserDO;
import com.sali.rbac.repository.ISysUserRepository;
import com.sali.repository.commons.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class SysUserRepositoryImpl extends BaseServiceImpl<SysUserMapper, SysUserDO> implements ISysUserRepository {

    @Autowired
    private SysUserConvertDO2Model sysUserConvertDO2Model;

    public SysUserModel selectBySysUserByAccount(String account){
        LambdaQueryWrapper<SysUserDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysUserDO::getAccount,account);
        SysUserDO sysUserDO = this.getOne(lambdaQueryWrapper);
        return sysUserConvertDO2Model.convert(sysUserDO);
    }

    public SysUserModel selectBySysUserById(Long id){
        SysUserDO sysUserDO = this.getById(id);
        return sysUserConvertDO2Model.convert(sysUserDO);
    }
}
